function fnAlertForm(){
	JFT.popupPage("brandSiteAction.do?method=queryBrands", "选择品牌", 800, 800);
}
function fnAlertTree(){
	JFT.popupPage("brandSiteAction.do?method=queryProdCate", "选择产品类别", 800, 800);
}

function fnAlertUserBrandForm(){
	JFT.popupPage("brandUserAction.do?method=findUsersList", "选择用户", 800, 800);
}
function fnAlertUserForm(){
	JFT.popupPage("brandUserAction.do?method=findBrandList", "选择品牌", 800, 800);
}
function fnAlertRemindForm(){
	JFT.popupPage("brandUserAction.do?method=findBrandList", "选择品牌", 800, 800);
}

function fnAlertCateTree(){
	JFT.popupPage("brandSiteItemCateAction.do?method=findSelectInfo", "选择产二级品类别", 800, 800);
}

(function(window){
	var cate={
	treeData:{},
	//渲染树形数据
	renderTreeNode:function(){
		var dataCode = $(this).attr("dataCode");
		if(Cate.treeData && Cate.treeData[dataCode]){
			Cate.toggleNode(dataCode);
			return;
		}
		Cate.loadAjax(dataCode, function(ds){
			var code = null;
			Cate.treeData[dataCode] = ds;
			var nodeLi = [];
			nodeLi.push('<ul id="node_'+dataCode+'">');
			for(var i=0; i<ds.length; i++){
				code = ds[i]["cateCode"];
				level = ds[i]["cateLevel"];
				if(level>=2){
					nodeLi.push('<li>');
					nodeLi.push('<label id="root_'+code+'" class="topic">');
					nodeLi.push('<input type="radio" name="cateInfo" id="rootIco_'+code+'" dataCode="'+code+'" dataName="'+ds[i]["cateName"]+'" value="'+code+'"/>');
					nodeLi.push('<span style="color:blue;cursor:pointer;" dataCode=' + code +' >'+ds[i]["cateName"]+'</a>');
					nodeLi.push('</label>');
					nodeLi.push('</li>');
				}else{
					nodeLi.push('<li>');
					nodeLi.push('<div id="root_'+code+'" class="topic">');
					nodeLi.push('<i id="rootIco_'+code+'" dataCode="'+code+'"></i>');
					nodeLi.push('<span dataCode=' + code +' style="color:blue;cursor:pointer;" >'+ds[i]["cateName"]+'</span>');
					nodeLi.push('</div>');
					nodeLi.push('</li>');
				}
			}
			nodeLi.push('</ul>');
			$("#root_"+dataCode).parent().append(nodeLi.join(""));
			$("#node_"+dataCode+ " i[dataCode]").click(Cate.renderTreeNode);
			$("#node_"+dataCode+ " span[dataCode]").click(Cate.renderTreeNode);
			nodeLi = null;
			Cate.toggleNode(dataCode);
		});
	},
	loadAjax:function(dataCode, callBackFunc){
		beginPageLoading();
		ajaxPost("prodCategoryAction.do?method=load", "dataCode="+dataCode, function(data){
			endPageLoading();
			if(data["resultCode"] != 0){
				alert("数据加载异常");
				return;
			}
			callBackFunc(data["resultData"]);
		});
	},

	toggleNode:function(dataCode){
		 $("#node_"+dataCode).slideToggle();
		 $("#root_"+dataCode).toggleClass("current");
	},
	//绑定tab事件
	bindTabEvent:function(menuId){
		
	}};
	window.Cate=cate;
})(window);

var windowCount = 0;

$(function(){
	// 模块选择下拉
	$(".c_tree .topic i").click(Cate.renderTreeNode);
	$(".c_tree .topic span").click(Cate.renderTreeNode);
});